{include file="public/header"/}
{include file="public/left"/}
      
    <div class="content">
        <div class="crumbs clr"><a href="{:url('admin/areas/edit',array())}"><span class="fr redBtn">新 建</span></a>运营管理 <span class="red">> 区域管理</span></div>
        <div class="whiteBox">
          <div class="clr pt20 pr20 pb20 pl30">
            <div class="search fr">
              <form action="{:url('admin/areas/index',array())}" method="get" id="searchform">
                搜索：
                <input type="text" id="keywords" value="{$keywords}" name="keywords" placeholder="请输入关键字">
                <span id="search"></span>
              </form>
            </div>
          </div>

          <table class="userTab">
            <tr>
              <th width="5%"></th>
              <th width="20%">序号</th>
              <th width="25%">区域名称</th>
              <th width="20%">操作</th>
            </tr>
            {volist name="list" id='item' key="key"}
            <tr data-id='{$item.id}'>
              <td><input rolename="{$item.area_name}" type="checkbox" name="checkmenu[]" value="{$item.id}"></td>
              <td>{$key}</td>
              <td>{$item.html}{$item.area_name}</td>
              <td>
                <span areaid="{$item.id}" class="edit" title="编辑"></span>
                <span areaid="{$item.id}" class="del" title="删除"></span>
              </td>
            </tr>
            {/volist}
          </table>
          <div class="pt40 pr20 pb40 pl40 clr">
            <span class="orangeBtn moreDel">删 除</span>
            <ul class="page fr">
              {$page}
            </ul>
          </div>
        </div>
        
    </div>

{include file="public/footer"/}

<script type="text/javascript">
$("#search").click(function(){
    var keywords = $("#keywords").val();
    $("#searchform").submit();
});

$(".edit").click(function(){
    var areaid=$(this).attr("areaid");
    var url = "{:url('admin/areas/edit')}?id="+areaid;
    location.href = url;   
});


$('.del').on('click',function(){
    var id = $(this).parents('tr').attr('data-id');
    layer.confirm('您确定要删除？', {
        btn: ['确认','取消'] //按钮
    }, function(index){
        del(id);
    }, function(){
    });
});

$('.moreDel').on('click',function(){
    $('.alert').hide();
    var menuids="";
    $("input[name='checkmenu[]']:checkbox:checked").each(function(){
        menuids+=$(this).val()+',';
    })
    if(!menuids){
        layer.alert("请选择需要删除的记录");
        return false;
    }
    layer.confirm('您确定要删除？', {
        btn: ['确认','取消'] //按钮
    }, function(index){
        delMore(menuids);
    }, function(){
    });
});

function del(id){
  $.ajax({
    url : "{:url('admin/areas/delAjax')}",
    type: "post",
    async: true,
      dataType:'json',
    data: {'id':id},
    success: function(data) {
      if(data.code==1){
          layer.alert(data.msg, function(index){
            location.reload();
          });
      }else{
          layer.alert(data.msg);
      }
    }
  });
}

function delMore(ids){
    $.ajax({
        url: "{:url('admin/areas/delMoreAjax')}",
        data:{
                 ids : ids,
        },
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
          if(data)
          {
             layer.alert(data.msg, function(index){
              location.reload();
              });
          }else{
            layer.alert(data.msg);
          }
        }
    });
}
</script>
</body>
</html>
    